﻿using System;
using System.Text;
using System.Linq;
using SampleApp.Domain;
using SampleApp.Data;
using System.Collections.Generic;
using COM.Service;

namespace SampleApp.Service
{
    static public class UnityExtension
    {
        static public IUnity RegisterSampleService(this IUnity unity)
        {
            RegisterSystemService(unity);
            RegisterSysModule(unity);
            return unity;
        }

        private static void RegisterSystemService(IUnity unity)
        {
            unity
                .RegisterSingleton<IDataCacheService, DataCacheService>()
                .Register<IDatabaseFactory, DatabaseFactory>()
                .Register<IUnitOfWork, UnitOfWork>()
                .Register<IAppLogRepository, AppLogRepository>()
                .Register<IAppLogService, AppLogService>()
                .Register<IRuntimeService, RuntimeService>()
                ;
        }

        private static void RegisterSysModule(IUnity unity)
        {
            unity
                .Register<ISysMenuRepository, SysMenuRepository>()
                .Register<ISysMenuService, SysMenuService>()
                .Register<ISysRoleRepository, SysRoleRepository>()
                .Register<ISysRoleMenuRepository, SysRoleMenuRepository>()
                .Register<ISysRoleService, SysRoleService>()

                .Register<ISysDeptRepository, SysDeptRepository>()
                .Register<ISysDeptService, SysDeptService>()
                .Register<ISysUserRepository, SysUserRepository>()
                .Register<ISysUserService, SysUserService>()
                .Register<ISysUserRoleRepository, SysUserRoleRepository>()

                //.Register<IAppLog2Repository, AppLog2Repository>()
                //.Register<IAppLog2Service, AppLog2Service>()
                ;
        }

    }

}
